{extend name="public/base" /}{block name="title"}<title>{$Think.lang.list}</title>{/block}{block name="pjax_container"}
<div class="hry-content-wrapper">
<section class="content-header">
    <ol class="breadcrumb">
        <li>合同管理</li>
        <li class="active">会员合同</li>
    </ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="hry-form-wrapper">
                <div class="box-header with-border"><h3 class="box-title"></h3>
                    <div class="pull-right"> {include file="public/mlist_search" /}</div>
                </div>
                <div class="box-body table-responsive">
                    <table class="table table-bordered table-hover table-sort">
                        <tr>
                            <th>{$Think.lang.id}{:table_sort('id')}</th>
                            <th>会员名称</th>
                            <th>身份证号</th>
                            <th>合同名称</th>
                            <th>合同编号</th>
                            <th>所属项目</th>
                            <th>金额</th>
                            <th>签署日期</th>
                            <th>签署状态</th>
                            <th>发送状态</th>
                            <th width="270">{$Think.lang.action}</th>
                        </tr>
                        {volist name="dataList" id="vo"}
                        <tr>
                            <td>{$vo.id}</td>
                            <td>{$vo.Member.username}</td>
                            <td>{$vo.certificate}</td>
                            <td>{$vo.title}</td>
                            <td>{$vo.contract_id}</td>
                            <td>{$vo.Project.project_name}</td>
                            <td>{$vo.money}</td>
                            <td>{$vo.date}</td>
                            <td> {if $vo.sign eq 3}签署成功{elseif $vo.sign eq 1}公司未签章{else}用户未签署{/if}</td>
                            <td> {if $vo.status eq 1}已发送{else}未发送{/if}</td>
                            <td><a class="btn-text btn-primary btn-xs" href="{:url('Hetong/detail',['id'=>$vo.id])}"
                                   target="_blank">查看</a>
                                <a class="btn-text btn-warning btn-xs " href="{:url('Hetong/dowonload',['id'=>$vo.id])}"
                                   target="_blank">下载</a>
                                {if $vo.sign eq 0}
                                <a class="btn-text btn-primary btn-xs userzc" data-id="{$vo.user_id}">用户注册</a>
                                <a class="btn-text btn-primary btn-xs userbq" data-id="{$vo.cid}"  data-uid="{$vo.user_id}" >用户补签</a>
                                {/if}
                                {if $vo.sign eq 1}
                                <a class="btn-text btn-primary btn-xs btnSubmit" data-id="{$vo.contract_id}">公司签章</a>
                                {elseif $vo.sign eq 2 }
                                <a class="btn-text btn-primary btn-xs userbf" data-id="{$vo.contract_id}">合同补发</a>
                                {/if}
                            </td>
                        </tr>
                        {/volist}
                    </table>
                </div>
                <div class="box-footer clearfix"> {$dataList->render()}</div>
            </div>
        </div>
    </div>
</section>
</div>
<script type="text/javascript">
    $(function () {    /*ajax页面加载icheck，有该控件的页面才需要*/
        $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
            checkboxClass: 'icheckbox_minimal-blue',
            radioClass: 'iradio_minimal-blue'
        });




        $('.userzc').click(function (e) {
            var user_id = $(this).data('id');
            console.log(user_id);
            $.ajax({
                url: 'userzc',
                data: {user_id: user_id},
                type: "POST",
                dataType: "json",
                success: function (result) {
                    if (result.status == 1) {
                        $.amaran({'message': '生成成功!'});
                        console.log(result);
                        // return false;
                        window.location.href = result.url;
                    } else {
                        $.amaran({'message': '生成失败!'});
                    }
                },
                error: function (result, xhr, status, errorThrown) {
                    $.amaran({'message': result.info})
                },
                complete: function (xhr, status) {
//                    alert('The request is complated');
                },
                beforesend: function () {
                },
                cache: false,//true
                async: true
            })
        });

        $('.userbq').click(function (e) {
            var cid = $(this).data('id');
            var user_id=$(this).data('uid');
            $.ajax({
                url: 'userbq',
                data: {cid: cid,user_id:user_id},
                type: "POST",
                dataType: "json",
                success: function (result) {
                    if (result.status == 1) {
                        $.amaran({'message': '补签成功!'});
                        console.log(result);
                        window.location.href = result.url;
                    }  else {
                        $.amaran({'message': '补签失败!'});
                    }
                },
                error: function (result, xhr, status, errorThrown) {
                    $.amaran({'message': result.info})
                },
                complete: function (xhr, status) {
//                    alert('The request is complated');
                },
                beforesend: function () {
                },
                cache: false,//true
                async: true
            })
        });

        $('.btnSubmit').click(function (e) {
            var contract_id = $(this).data('id');
            console.log(contract_id);
            $.ajax({
                url: 'comcre',
                data: {contract_id: contract_id},
                type: "POST",
                dataType: "json",
                success: function (result) {
                    if (result.status == 1) {
                        $.amaran({'message': '盖章成功!'});
                        console.log(result);
                        window.location.href = result.url;
                    }  else {
                        $.amaran({'message': '盖章失败!'});
                    }
                },
                error: function (result, xhr, status, errorThrown) {
                    $.amaran({'message': result.info})
                },
                complete: function (xhr, status) {
//                    alert('The request is complated');
                },
                beforesend: function () {
                },
                cache: false,//true
                async: true
            })
        });

        $('.userbf').click(function (e) {
            var contract_id = $(this).data('id');
            console.log(contract_id);
            $.ajax({
                url: 'userbf',
                data: {contract_id: contract_id},
                type: "POST",
                dataType: "json",
                success: function (result) {
                    if (result.status == 1) {
                        $.amaran({'message': '补发成功!'});
                        console.log(result);
                        window.location.href = result.url;
                    } else {
                        $.amaran({'message': '补发失败!'});
                    }
                },
                error: function (result, xhr, status, errorThrown) {
                    $.amaran({'message': result.info})
                },
                complete: function (xhr, status) {
//                    alert('The request is complated');
                },
                beforesend: function () {
                },
                cache: false,//true
                async: true
            })
        });


        /*ajax页面加载icheck，有该控件的页面才需要*/
        $(".select2").select2({language: "zh-CN"});
        /*全选-反选*/
        $('.checkbox-toggle').on('ifChecked', function (event) {
            var _this = $(this);
            var _table = _this.closest('.table');
            _table.find("tr td input[type='checkbox']").iCheck("check");
        });
        $('.checkbox-toggle').on('ifUnchecked', function (event) {
            var _this = $(this);
            var _table = _this.closest('.table');
            _table.find("tr td input[type='checkbox']").iCheck("uncheck");
        });

        $('.editable').editable({
            emptytext: "empty",
            params: function (params) {
            }
        });

    });
</script>
{/block}